﻿using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Cine;
using Moq;

namespace CineTest
{
    [TestClass]
    public class UnitTestVentaController
    {
        private VentaController sut;

        private Mock<IVentaService> mock;

        private Sala sala1;
        private Sesion sesion1;
        private Sesion sesion2;

        private Venta venta1;
        private Venta venta1Resultado;

        [TestInitialize]
        public void TestInicializa()
        {
            sala1 = new Sala(1,100);

            sesion1 = new Sesion(1, sala1);
            sesion2 = new Sesion(2, sala1);

            venta1 = new Venta(sesion1,5,7);
            venta1Resultado = new Venta(sesion1,5,7);
            venta1Resultado.Id = 1;

            mock = new Mock<IVentaService>();
            sut = new VentaController();
            sut.Servicio = mock.Object;
        }

        [TestMethod]
        public void TestMethodCreate()
        {
            mock.Setup(service => service.Create(venta1)).Returns(venta1Resultado);

            Venta resultado1 = sut.Create(venta1);

            Assert.AreEqual(1, resultado1.Id);
        }

        [TestMethod]
        public void TestMethodTotalVentas()
        {
            mock.Setup(service => service.CalcularTotalVentas()).Returns(21.0);

            double resultado = sut.TotalVentas();

            Assert.AreEqual(21.0, resultado, 0.001, "Error total ventas");
        }
    }
}
